/**************************************************************************
* This file is part of Hawkengine.
*
* Hawkengine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hawkengine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#ifndef _IMAGE_H_
#define _IMAGE_H_

/**************************************************************************
* Dependencies
**************************************************************************/
#include "engine/common.h"
#include "engine/color.h"
 
/**************************************************************************
* Preprocessing
**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

/**************************************************************************
* Types
**************************************************************************/
typedef enum
{
  IMAGE_DATA_CHANNELS,
  IMAGE_DATA_INTENSITY,
  IMAGE_DATA_EDGE,
  IMAGE_DATA_ENERGY_H,
  IMAGE_DATA_ENERGY_V,
  IMAGE_DATA_SEAM_H,
  IMAGE_DATA_SEAM_V,
  IMAGE_DATA_COUNT,
} image_data_type;

typedef struct
{
  int width;
  int height;
  int channels;
  UCHAR* data[IMAGE_DATA_COUNT];
} image_type;

/**************************************************************************
* Variables
**************************************************************************/

/**************************************************************************
* Static Variables
**************************************************************************/

/**************************************************************************
* Function Prototypes
**************************************************************************/
void image_add_seam(image_type* image, BOOL horizontal);
void image_calculate(image_type* image, image_data_type image_data);
void image_clone(const image_type* image, image_type* new_image);
void image_create(int width, int height, int channels, image_type* image);
BOOL image_create_from_file(const file_data_type* file_data, image_type* image);
void image_destroy(image_type* image);
void image_flip(image_type* image, BOOL horizontal);
void image_init(void);
void image_remove_seam(image_type* image, BOOL horizontal);
void image_resize(image_type* image, int width, int height);
UINT image_texture(const image_type* image, image_data_type image_data);
UINT image_texture_from_data(const file_data_type* file_data);
UINT image_texture_from_data_add_alpha(const file_data_type* file_data,
                                       const color_type* transparent_color);
void image_uninit(void);
BOOL image_write(image_type* image, image_data_type image_data,
                 const char* type, UCHAR** file_data, int* file_size);

/**************************************************************************
* Function Implementations
**************************************************************************/


#ifdef __cplusplus
}
#endif

#endif
